package lianxi;

import java.util.Random;

public class test02 {
    public static void main(String[] args) {
        int[] arr = new int[10];

        Random r = new Random();

        System.out.println("随机生成的数组为：");
        for (int i = 0; i < arr.length; i++) {
            arr[i] = r.nextInt(101);
        }

        print(arr);

        int oushu = oushu(arr);
        System.out.println("偶数个数为：" + oushu);

        int jishu = jishu(arr);
        System.out.println("奇数个数为：" + jishu);

        int getmax = getmax(arr);
        System.out.println("最大值为：" + getmax);

        int getmin = getmin(arr);
        System.out.println("最小值为：" + getmin);

    }


    public static void print(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                System.out.print(arr[i]);
            } else {
                System.out.print(arr[i] + " ,");
            }
        }
        System.out.println("]");
    }



    public static int jishu(int[] arr) {
        int jishucount = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0) {
                jishucount++;
            }
        }
        return jishucount;
    }

    public static int oushu(int[] arr) {
        int oushucount = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0) {
                oushucount++;
            }
        }
        return oushucount;
    }

    public static int getmax(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        return max;
    }

    public static int getmin(int[] arr) {
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        return min;
    }
}